package bishi.day28_5_26;

import java.util.*;

/**
 * @author 是阿秋啊
 * @date 2022/05/26 12:43
 **/
class Node {
    int val;
    Node next;

    public Node(int val) {
        this.val = val;
    }
}

public class reverse_ListNode {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node head = new Node(sc.nextInt());
        Node cur = head;
        for (int i = 1; i < n; i++) {
            int val = sc.nextInt();
            Node node = new Node(val);
            cur.next = node;
            node.next = null;
            cur = cur.next;
        }
        int l = sc.nextInt();
        int r = sc.nextInt();
        head = reverse(head, l, r);
        while (head != null) {
            System.out.print(head.val+" ");
            head=head.next;
        }
    }

    private static Node reverse(Node head, int l, int r) {
        Node dummyHead = new Node(-1000001);
        dummyHead.next = head;
        Node pre = dummyHead;
        for (int i = 1; i < l; i++) {
            pre = pre.next;
        }
        Node cur = pre.next;
        for (int i = 0; i < r - l; i++) {
            Node tmp = cur.next;
            cur.next = tmp.next;
            tmp.next = pre.next;
            pre.next = tmp;
        }
        return dummyHead.next;
    }
}